package com.rec.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.rec.entity.ConsumeLogs;
import com.rec.service.StatisticService;

@RestController
@RequestMapping("/statistics")
@CrossOrigin
public class StatisticsController {
	
	@Autowired
	private StatisticService s;
	
	@RequestMapping("getAll")
	public Map<String,Object> getBySearch(Integer readroomid,String begin,String end,
			Integer page, Integer limit) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("readroomid", readroomid);
		params.put("begin", begin);
		params.put("end", end);
		limit = limit == null ? 10 : limit;
		page = page == null ? 0 : page - 1;
		params.put("limit", limit);
		params.put("page", page);
		System.out.println(s.all(params));
		return s.all(params);
	}
	@RequestMapping("getT")
	public List<ConsumeLogs> getTest(){
		return s.getTest();
	}
}
